from typing import List

class Solution:
    def canJump(self, nums: List[int]) -> bool:

        
        if not nums:
            return False
            
        max_reach = 0  # 记录能够到达的最远位置
        
        for i, num in enumerate(nums):
            if i > max_reach:
                return False
            
            max_reach = max(max_reach, i + num)
            
            if max_reach >= len(nums) - 1:
                return True
        
        return False

def main() -> None:
    """主函数，用于测试"""
    solution = Solution()
    test_cases = [
        ([2, 3, 1, 1, 4], True),    # 测试用例1
        ([3, 2, 1, 0, 4], False),   # 测试用例2
        ([0], True),                # 测试用例3：只有一个元素
        ([1, 0, 1, 0], False),      # 测试用例4：无法到达终点
    ]
    
    for nums, expected in test_cases:
        result = solution.canJump(nums)
        print(f"输入: {nums}")
        print(f"预期输出: {expected}")
        print(f"实际输出: {result}")
        print(f"测试{'通过' if result == expected else '失败'}\n")

if __name__ == "__main__":
    main() 